#if 1

typedef unsigned int uint32;

#include <windows.h>
#include <stdio.h>

//	bitmap;

class Bitmap
{
public:
	Bitmap()
	{
		uint32 len = (uint32(~0)) >> 3;
		arr = (byte*)malloc(len * sizeof(byte));
		memset(arr, 0 , len);
	};
	~Bitmap()
	{
		free(arr);
	};

	bool AddNum(uint32 num);
	bool DelNum(uint32 num);
	bool IsNumExist(uint32 num);
private:

private:
	byte* arr;
};

bool Bitmap::AddNum(uint32 num)
{
	int index = num >> 3;
	int move = 1 << (num % 8);
	if (move & arr[index])
	{
		return false;
	}

	arr[index] |= move;
	return true;
}

bool Bitmap::DelNum(uint32 num)
{
	int index = num >> 3;
	int move = 1 << (num % 8);
	if (!(move & arr[index]))
	{
		return false;
	}

	arr[index] &= ~move;
	return true;
}

bool Bitmap::IsNumExist(uint32 num)
{
	int index = num >> 3;
	byte move = 1 << (num % 8);
	return (move & arr[index]) > 0;
}

#if 0

int main()
{
	const int len = 128;
	int arr[len] = { 0 };
	for (size_t j = 0; j < 10; j++)
	{
		Bitmap bitmap;
		srand(time(NULL));
		for (size_t i = 0; i < len; i++)
		{

			arr[i] = rand();
			//printf("%d\n", arr[i]);
			assert(bitmap.AddNum(arr[i]));
			assert(bitmap.IsNumExist(arr[i]));
			assert(bitmap.DelNum(arr[i]));
		}
	}

	getchar();
	return 0;
}


#endif // 0

#endif // 0
